import Vue from 'vue'
import VueRouter from 'vue-router'

//引入布局组件
import Layout from '@/views/Layout/index.vue'
Vue.use(VueRouter)

const routes = [{
        path: '/',
        name: 'Login',
        redirect: "login",
        hidden: true,
        meta: {
            name: '主页'
        }
    },
    {
        path: '/login',
        name: 'Home',
        hidden: true,
        meta: {
            name: '登录'
        },
        component: () =>
            import ('../views/Login/index.vue')
    },
    /**
     * 控制台
     */
    {
        path: '/console',
        name: 'Console',
        redirect: '/index',
        // 自定义参数
        meta: {
            name: '控制台',
            icon: 'console'
        },
        component: Layout,
        children: [{
            path: '/index',
            name: 'Index',
            // 自定义参数
            meta: {
                name: '首页'
            },
            component: () =>
                import ('../views/Console/index.vue')
        }]

    },

    /**
     * 信息管理
     */
    {
        path: '/info',
        name: 'Info',
        meta: {
            name: '信息管理',
            icon: 'menu'
        },
        component: Layout,
        children: [{
                path: '/infoIndex',
                name: 'InfoIndex',
                meta: {
                    name: '信息列表'
                },
                component: () =>
                    import ('../views/Info/index.vue')
            },
            {
                path: '/infoCategory',
                name: 'InfoCategory',
                meta: {
                    name: '信息分类'
                },
                component: () =>
                    import ('../views/Info/category.vue')
            }
        ]

    },
    /**
     * 用户管理
     */
    {
        path: '/user',
        name: 'User',
        meta: {
            name: '用户管理',
            icon: 'user'
        },
        component: Layout,
        children: [{
            path: '/userindex',
            name: 'UserIndex',
            meta: {
                name: '用户列表'
            },
            component: () =>
                import ('../views/User/index.vue')
        }, ]

    },
]

const router = new VueRouter({
    routes,
    // setup() {
    //     const originalPush = VueRouter.prototype.push
    //     VueRouter.prototype.push = function push(location, onResolve, onReject) {
    //         if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
    //         return originalPush.call(this, location).catch(err => err)
    //     }

    // }
})



export default router